package cn.itsource.xhy.pet.service.impl;

import cn.itsource.xhy.basic.service.impl.BaseServiceImpl;
import cn.itsource.xhy.pet.domain.Pet;
import cn.itsource.xhy.pet.domain.PetDetail;
import cn.itsource.xhy.pet.mapper.PetDetailMapper;
import cn.itsource.xhy.pet.mapper.PetMapper;
import cn.itsource.xhy.pet.service.IPetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PetServiceImpl extends BaseServiceImpl<Pet> implements IPetService {

    @Autowired
    private PetDetailMapper petDetailMapper;

    @Autowired
    private PetMapper petMapper;

    @Override
    public void save(Pet pet) {
        super.save(pet);
        // 拿到detail对象
        PetDetail detail = pet.getDetail();
        // 将petid设置到detail
        detail.setPet_id(pet.getId());
        // 保存数据
        petDetailMapper.save(detail);
    }

    @Override
    public void onSale(Long[] ids) {
        petMapper.onSale(ids);
    }

    @Override
    public void downSale(Long[] ids) {
        petMapper.downSale(ids);
    }

    @Override
    public Pet findByPetId(Long id) {
        return petMapper.findByPetId(id);
    }
}
